function pageX(elem){
	return elem.offsetParent ?
		elem.offsetLeft + pageX(elem.offsetParent) :
		elem.offsetLeft;
}

function pageY(elem){
	return elem.offsetParent ?
		elem.offsetTop + pageY(elem.offsetParent) :
		elem.offsetTop;
}

function parentX(elem){
	return elem.parentNode == elem.offsetParent ?
		elem.offsetLeft :
		pageX(elem) - pageX(elem.parentNode);
}

function parentY(elem){
	return elem.parentNode == elem.offsetParent ?
		elem.offsetTop :
		pageY(elem) - pageY(elem.parentNode);
}

function posX(elem){
	return parseInt(getStyle(elem, "left"));
}

function posY(elem){
	return parseInt(getStyle(elem, "top"));
}

function setX(elem, pos){
	elem.style.left = pos + "px";
}

function setY(elem, pos){
	elem.style.top = pos + "px";
}

function getHeight(elem){
	return parseInt(getStyle(elem, "height"));
}

function getWidth(elem){
	return parseInt(getStyle(elem, "width"));
}

function fullHeight(elem){
	if(getStyle(elem, 'display') != 'none')
		return elem.offsetHeight || getHeight(elem);

	var old = resetCSS(elem, {
		display: '',
		visibility: 'hidden',
		position: 'absolute'
	});

	var h = elem.clientHeight || getHeight(elem);

	restoreCSS(elem, old);

	return h;
}

function fullWidth(elem){
	if(getStyle(elem, 'display') != 'none')
		return elem.offsetWidth || getWidth(elem);

	var old = resetCSS(elem, {
		display: '',
		visibility: 'hidden',
		position: 'absolute'
	});

	var w = elem.clientWidth || getWidth(elem);

	restoreCSS(elem, old);

	return w;
}

function resetCSS(elem, prop){
	var old = {};
	
	for(var i in prop){
		old[i] = elem.style[i];
		elem.style[i] = prop[i];
	}

	return old;
}

function restoreCSS(elem, prop){
	for(var i in prop)
		elem.style[i] = prop[i];
}